import request from '@/utils/request'

// 从配置中获取业务的地址
import { baseUrlConfig } from '@/config/config'
const basePath = baseUrlConfig.businessBaseUrl

export interface PageListType {
  pageNum?: number
  pageSize?: number
  serviceName: string
  recorder: string
  startTime: string
  endTime: string
  condition: {
    region: string[]
    enquiryType: string[]
    order: string[]
  }
}

export interface SearchListType {
  deviceId: string
  problemType: string
  organ: string
}

// 获取分页列表
export const problemPageList: (data: PageListType) => Promise<[]> = (
  data: PageListType
) => {
  return request({
    url: basePath + '/pax/love/find/page',
    method: 'post',
    data: {
      pageSize: data.pageSize,
      pageNum: data.pageNum,
      condition: {
        recorder: data.recorder,
        serviceName: data.serviceName,
        serviceTimeEnd: data.endTime,
        serviceTimeStart: data.startTime,
        serviceType: data.condition.region,
        serviceTypeChild: data.condition.enquiryType,
        order: data.condition.order
      }
    }
  })
}

// 导出
export const loveExport = (data: FilterDataType) => {
  return request({
    url: basePath + '/pax/love/export',
    method: 'post',
    responseType: 'blob',
    data
  })
}
